#ifndef YOOHOO_XMPPCORE_STREAMFEATURES_H
#define YOOHOO_XMPPCORE_STREAMFEATURES_H

#include "xmppcore/export.h"

#include <QtCore/QString>
#include <QtCore/QXmlStreamReader>

namespace yoohoo_xmppcore {

class YOOHOO_XMPPCORE_EXPORT StreamFeature {
public:
	StreamFeature(QString name, QString namespaceUri);
	~StreamFeature() {}
	const QString& name() const;
	const QString& namespaceUri() const;
	virtual bool fromXml(QXmlStreamReader& reader) = 0;

protected:
	QString _name;
	QString _namespaceUri;
};

class YOOHOO_XMPPCORE_EXPORT StreamFeatures {
public:
	~StreamFeatures();
	bool matches(QString& xml);
	bool fromXml(QString& xml);
	StreamFeature* getStreamFeature(const QString& name, const QString& namespaceUri);
	void registerSupportedStreamFeature(StreamFeature* supported);
	const QList<StreamFeature*>& streamFeatures() const;
private:
	QList<StreamFeature*> features;
	QList<StreamFeature*> supportedFeatures;

	enum ReadStreamFeatureState {
		ReadOne,
		Error,
		DoNothing
	};

	ReadStreamFeatureState readStreamFeature(QXmlStreamReader& reader);
};

}

#endif
